import { defineStore } from 'pinia'
import { ref } from 'vue'
import { computed } from 'vue'
export const useMessageStore = defineStore('message', () => {
  //我的消息的总未读数
  const myMessageCount = ref(0)
  //回复我的消息未读总数
  const replyMessageCount = ref(0)
  //@我的消息未读总数
  const atMessageCount = ref(0)
  //收到的赞的消息未读数
  const likeMessageCount = ref(0)


  //一共的未读数
  const totalMessageCount = computed(() => {
    return myMessageCount.value + replyMessageCount.value + atMessageCount.value + likeMessageCount.value
  })

  //设置我的消息的总未读数
  function setMyMessageCount(newCount) {
    myMessageCount.value = newCount
  }
  function increMyMessageCount() {
    console.log("11111")
    myMessageCount.value = myMessageCount.value + 1;
    console.log(myMessageCount.value)
  }
  function decreMyMessageCount() {
    myMessageCount.value = myMessageCount.value - 1;
  }
  //设置回复我的消息未读总数
  function setReplyMessageCount(newCount) {
    replyMessageCount.value = newCount
  }
  function increReplyMessageCount() {
    replyMessageCount.value = replyMessageCount.value + 1;
  }
  //设置@我的消息未读总数
  function setAtMessageCount(newCount) {
    atMessageCount.value = newCount
  }
  function increAtMessageCount() {
    atMessageCount.value = atMessageCount.value + 1;
  }
  //设置收到的赞的消息未读数
  function setLikeMessageCount(newCount) {
    likeMessageCount.value = newCount
  }
  function increLikeMessageCount() {
    likeMessageCount.value = likeMessageCount.value + 1
  }
  return {
    myMessageCount, replyMessageCount, atMessageCount, likeMessageCount, totalMessageCount,
    setMyMessageCount, increReplyMessageCount, increAtMessageCount, increLikeMessageCount,
    setReplyMessageCount, setAtMessageCount, setLikeMessageCount, increMyMessageCount, decreMyMessageCount
  }

})